<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
		let listA = [
		    {"id":"1","title": "威海2018年体育中考内容出炉炉","date":"20180212"},
		    {"id":"2","title": "小年开始威海市区将进入亮灯模","date":"20180211"},
		    {"id":"3","title": "威海市图书馆2月8日免费送春","date":"20180208"},
		    {"id":"4","title": "92号汽油每升上涨5分钱分钱分","date":"20180208"},
		    {"id":"5","title": "市民可免费领手绘版“威海文化","date":"20180208"},
		    {"id":"6","title": "首批52辆新能源车23日上牌分","date":"20180208"},
		    {"id":"7","title": "高区幼儿园招聘24名幼儿教师","date":"20180207"},
		    {"id":"8","title": "威海-北京新增春节加班航班炉","date":"20180207"}
		];
		 function dateToStr(formatStr, date){
			formatStr = arguments[0] || "yyyy-MM-dd HH:mm:ss";
			date = arguments[1] || new Date();
			var str = formatStr;   
			var Week = ['日','一','二','三','四','五','六'];  
			str=str.replace(/yyyy|YYYY/,date.getFullYear());   
			str=str.replace(/yy|YY/,(date.getYear() % 100)>9?(date.getYear() % 100).toString():'0' + (date.getYear() % 100));   
			str=str.replace(/MM/,date.getMonth()>9?(date.getMonth() + 1):'0' + (date.getMonth() + 1));   
			str=str.replace(/M/g,date.getMonth());   
			str=str.replace(/w|W/g,Week[date.getDay()]);   
		  
			str=str.replace(/dd|DD/,date.getDate()>9?date.getDate().toString():'0' + date.getDate());   
			str=str.replace(/d|D/g,date.getDate());   
		  
			str=str.replace(/hh|HH/,date.getHours()>9?date.getHours().toString():'0' + date.getHours());   
			str=str.replace(/h|H/g,date.getHours());   
			str=str.replace(/mm/,date.getMinutes()>9?date.getMinutes().toString():'0' + date.getMinutes());   
			str=str.replace(/m/g,date.getMinutes());   
		  
			str=str.replace(/ss|SS/,date.getSeconds()>9?date.getSeconds().toString():'0' + date.getSeconds());   
			str=str.replace(/s|S/g,date.getSeconds());   
		  
			return str;   
		}
		let aa = dateToStr('YYYYMMDD');
		console.log(aa)


		function changeDate(arr) {
		    const a = {};		    
		    const today = dateToStr('YYYYMMDD');
		    arr.forEach((v,index)=>{
		        const c = today - v.date;
		        if(c == 0){
		        	v.date = 'a'
		        }else if (c ==1) {
		        	v.date = 'b';
		        }else{
		        	v.date = 'c';
		        }
		        a[index] =[]
		        a[index].push(v)
		    })
		    return a
		}

	let d = changeDate(listA);
	console.log(d)
	</script>
</body>
</html>